$(function(){
	$("img.lazy").lazyload({ threshold : 200 });
	

	/*焦点图*/
	var iswiperCont = $('.index-swiper');
	var indexSwiper = new Swiper('.swiper-container.index-swiper', {
	    pagination: '.swiper-pagination',
	    paginationClickable: true,
	    spaceBetween: 30,
	    autoplay: 4000,
	    loop: true
	});
	iswiperCont.find('.swiper-button-prev').on('click', function(e){
		e.preventDefault();
		indexSwiper.swipePrev();
	});
	iswiperCont.find('.swiper-button-next').on('click', function(e){
		e.preventDefault();
		indexSwiper.swipeNext();
	});

	iswiperCont.mouseenter(function(){
		indexSwiper.stopAutoplay();
	});
	iswiperCont.mouseleave(function(){
		indexSwiper.startAutoplay();
	});


	/*switchable hover*/
	function hoverOnSlideNav(obj, api) {
		obj.find('.prev').hover(function() {
			api.pause();
		}, function() {
			api.play();
		});

		obj.find('.next').hover(function() {
			api.pause();
		}, function() {
			api.play();
		});
	}

	/*subfocus*/
	var sfSlide = $('.subfocus-slide'),
		sfTriggers = sfSlide.find('.triggers a'),
		sfPanels = sfSlide.find('.cont li');
	var subfocusApi = sfSlide.switchable({
	    triggers: sfTriggers,
	    panels: sfPanels,
	    effect: 'fade',
	    easing: 'linear',
	    autoplay: false,
	    interval: 5,
	    onSwitch: function (e, index) {
	    },
	    api: true
	});


	/*event*/
	var eventList =  $('.event-list'),
		eventSlide = $('.event-slide'),
		eventPanels = eventSlide.find('ul li'),
		eventPrev = eventSlide.find('.prev'),
		eventNext = eventSlide.find('.next');
	var eventApi = eventList.switchable({
	    triggers: null,
	    panels: eventPanels,
	    effect: 'scrollLeft',
	    easing: 'ease-in-out',
	    visible: 4,
	    prev: eventPrev,
		next: eventNext,
		autoplay: true,
		end2end: true,
		interval: 5,
		api: true,
		onSwitch: function (e, index) {
			eventList.find('.switchable-cloned .lazy').each(function(){
	    		$(this).attr('src',$(this).attr('data-original'));
	    	});
	    }
	});
	hoverOnSlideNav(eventSlide , eventApi);


	/*feature*/
	var featureList =  $('.feature-list'),
		featureSlide = $('.feature-slide'),
		featurePanels = featureSlide.find('ul li'),
		featurePrev = featureSlide.find('.prev'),
		featureNext = featureSlide.find('.next');
	var featureApi = featureList.switchable({
	    triggers: null,
	    panels: featurePanels,
	    effect: 'scrollLeft',
	    easing: 'ease-in-out',
	    steps: 4,
	    visible: 4,
	    prev: featurePrev,
		next: featureNext,
		autoplay: true,
		end2end: true,
		interval: 5,
		api: true
	});
	hoverOnSlideNav(featureSlide , featureApi);

	

	/*One Bazaar*/
	var onePagination = $('.one-bazaar-container .swiper-pagination');
	var onebazaar = new Swiper('.one-bazaar-container', {
		pagination: '.one-bazaar-container .swiper-pagination',
		slidesPerView: 4,
		paginationClickable: true,
		freeMode: true,
		autoplay: 3000
	});
	$(".one-bazaar-slider").hover(function(){
		onebazaar.stopAutoplay();
	},function(){
		onebazaar.startAutoplay();
	});

	$('.one-bazaar-link').mouseenter(function(){
		$(this).find('.one-bazaar-qr').fadeIn();
	})
	$('.one-bazaar-link').mouseleave(function(){
		$(this).find('.one-bazaar-qr').fadeOut();
	});
	var l = onePagination.find('span').length -4;
	onePagination.find('span:gt('+l+')').remove();



	

	

	
});











